﻿using Data0426.Base.Common;
using Data0426.Base.Dommain;
using Data0426.Base.Read.API.Applaction.Command;
using Data0426.Base.Write.API.Applaction.Command;
using MediatR;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;

namespace Data0426.Base.Write.API.Controllers
{
    [Route("api/[controller]/[action]")]
    [ApiController]
    public class FormsController : ControllerBase
    {
        private readonly IMediator mediator;

        public FormsController(IMediator mediator)
        {
            this.mediator = mediator;
        }

        /// <summary>
        /// 添加表单类型
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        [HttpPost]
        public Task<ApiResult<int>> CreateForm(CreateFormTypeCommand request)
        {
            return mediator.Send(request);
        }

        /// <summary>
        /// 修改表单
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        [HttpPut]
        public Task<ApiResult<int>> UpdateForm(UpdateCommand request)
        {
            return mediator.Send(request);
        }
    }
}
